
//
//  gaojisousuoViewController.m
//  tongxiangOASystem
//
//  Created by michael on 2018/4/24.
//  Copyright © 2018年 czd. All rights reserved.
//

#import "gaojisousuoViewController.h"
#import "swyishouresultViewController.h"
@interface gaojisousuoViewController ()

@end

@implementation gaojisousuoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
      self.view.backgroundColor = [UIColor colorWithHexString:@"efeff4"];
   

     NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute fromDate:[NSDate date]];
    _year = [components year];
    _yearstring = [NSString stringWithFormat:@"%ld",(long)_year];
// NSInteger firstYear = 2018;
    NSMutableArray *yearArray = [NSMutableArray array];
    for (int i = 0; i <= _year-2000; i++) {
        [yearArray addObject:[NSString stringWithFormat:@"%ld", _year - i]];
    }
    _yearArray = yearArray;

  UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 45+10,50, 40)];
  label1.textColor = [UIColor colorWithHexString:@"484848"];
label1.text = @"文号:";
    label1.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:label1];
    _textField1 = [[zhucetextfield alloc]init];
     _textField1.delegate = self;
 _textField1.frame = CGRectMake(label1.right+ 10, label1.top, (KScreenWidth-80), 40);
    [self.view addSubview:_textField1];

UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(10,label1.bottom+10,50, 40)];
  label2.textColor = [UIColor colorWithHexString:@"484848"];
label2.text = @"关键字:";
    label2.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:label2];
    _textField2 = [[zhucetextfield alloc]init];
     _textField2.delegate = self;
 _textField2.frame = CGRectMake(label2.right+ 10, label2.top, (KScreenWidth-80), 40);
    [self.view addSubview:_textField2];

 UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
      button1.frame = CGRectMake(KScreenWidth/2-50, _textField2.bottom+ 20, 100, 40);
          button1.backgroundColor = [UIColor colorWithHexString:@"0e75de"];

    [button1 setTitle:@"搜索" forState:UIControlStateNormal];
    button1.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [button1 setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
        button1.layer.cornerRadius = button1.height/4;
                [button1 addTarget:self action:@selector(action1) forControlEvents:UIControlEventTouchUpInside];

            [self.view addSubview:button1];
            UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(10,5,50, 40)];
  label3.textColor = [UIColor colorWithHexString:@"484848"];
label3.text = @"年度:";
    label3.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:label3];
             _yearMenu = [[HJDropDownMenu alloc] initWithFrame:CGRectMake(label3.right+10, 5, KScreenWidth-80, 40)];
    _yearMenu.rowHeight = 40;
    _yearMenu.datas = _yearArray;
    [self.view addSubview:_yearMenu];
                     __weak typeof(self) weakSelf = self;

    [_yearMenu setCellClickedBlock:^(NSString *title, NSInteger index) {
weakSelf.yearstring = title;
[weakSelf.yearMenu closeMenu];
}];
    // Do any additional setup after loading the view.
}
- (void)action1{
NSString *text1=[_textField1.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *text2=[_textField2.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

//if ([text1 isEqualToString:@""]|| text1.length == 0) {
//  [self.view makeToast:@"文号为空"];
//
//}else

 if(([text2 isEqualToString:@""]|| text2.length == 0)&&([text1 isEqualToString:@""]|| text1.length == 0)){
     [self.view makeToast:@"请输入搜索条件"];
}else if([_yearstring isEqualToString:@""]|| _yearstring.length == 0){
     [self.view makeToast:@"年度为空"];
}else{
swyishouresultViewController *vc = [[swyishouresultViewController alloc]init];
vc.hidesBottomBarWhenPushed = YES;
vc.condition =text2;
vc.zh =text1;
vc.year =_yearstring;
[self.navigationController pushViewController:vc animated:YES];
}
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[_yearMenu closeMenu];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
